Chris Pollett >
Old
Classes > |
HW#3 --- last modified February 28 2019 22:25:36..Due date: Apr 6
Files to be submitted: Purpose: To gain a first-hand knowledge of variable scoping by examining assembly code output. To learn about different approaches to the object-oriented programming language paradigm. Related Course Outcomes: The main course outcomes covered by this assignment are: LO2 -- Have a basic knowledge of the procedural, object-oriented, functional, and logic programming paradigms. LO4 -- Critique the design of a programming language LO7 -- Understand variable scoping and lifetimes. Specification: For this homework I want you to code a text-based interface, so that two people can play the game Chomp. I actually want you to code this twice: once in C++, and once using Objective-C. The grader will unzip your project, switch into that directory, and type "make chompcplusplus" to build the C++ version and type "make chompobjectivec" to build the Objective-C version of your project. Both versions produce an executable named chomp. So the grader can then type "./chomp" to execute the given program. Your program should then print: Please enter the length of the chocolate bar: And allows the user to enter an positive integer chocolate bar length less than 20. After this has been done. The program should print: Please enter the width of the chocolate bar: And allows the user to enter an positive integer chocolate bar width less than 40. Then the program should using character graphics draw the game board, say it is Player A's turn, and ask for a move of Player A. For a 3x5 board, this might look like: Player A's Turn 1 2 3 4 5 1 O X X X X 2 X X X X X 3 X X X X X Please enter the row of the move for Player A: After this is entered it asks for the column of the move for A. Your program should check if the move is legal. If not, it should get the user to enter the move again. If it is legal, the program should draw the resulting board. and prompt for a move for Player B. And so on. Note both player's are assumed to be humans, you are NOT writing an AI for this game. After each turn your programs should be checking, if someone has eaten the poisoned chocolate square and if so declare a winner. Your programs then may ask if the player's want to play another game. For both implementations of chomp I want you to write at least three classes. I also want you to make use of both public and private variables, public and private member functions. You should have at least one class that inherits from some other class. Your programs should each make use of one language construct that is not available in the other language. As part of your make commands, I want you to compile each of your programs to assembly. Next I want you to look at the assembly for both your C++ and Objective-C programs and answer the following questions:
Put your answers in the file answers.txt. Make sure to list all group members at the start of the file. Include code snippets from your original code and assembly code which prove each of your answers. Answers without sufficient explanation will receive little credit. Point Breakdown
|